
import LanguageType from "../Managers/LanguageType";

export default class GameDataUtilTs{

    //被从游戏中提出来，原因是钱不够了
    public static isKickCauseNoMoney : boolean = false

    public static LoginMethod = {
        GUEST:"guest",
        MOBILE:"mobile",
    }

    // onLoad () {}

    start () {

    }

    // update (dt) {}

    //获取用户最近一次的登录方式
    public static getLoginType () {
        let typeString = cc.sys.localStorage.getItem('login_method')
        cc.log("取出的login_method：",typeString)
        return typeString;
    }

    public static getCurrentSceneName () : string{
        let sceneName = cc.director.getScene().name
        return sceneName
    }

    public static getDefaultLanguage () {
        if(cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID){
            var defaultLanguage = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "getDefaultLanguage","()I") || LanguageType.ENGLISH
            console.log("默认语言：",defaultLanguage)
            return defaultLanguage;
        }else if ( cc.sys.os == cc.sys.OS_IOS ){
            return "0"
        }else {
            return LanguageType.ENGLISH
        }
    }

    public static getUseTestServer () {
        if(cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID){
            var defaultLanguage = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "getUseTestServer","()I") || 0
            console.log("使用测试服：",defaultLanguage)
            return defaultLanguage;
        }else if ( cc.sys.os == cc.sys.OS_IOS ){
            return "0"
        }else {
            return 0
        }
    }

    public static getIsAllHorizontal () {   //0是竖屏 1是横屏
        if(cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID){
            var defaultLanguage = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "getIsAllHorizontal","()I") || 0;
            console.log("是否全部显示横屏：",defaultLanguage)
            return parseInt(defaultLanguage);
        }else if ( cc.sys.os == cc.sys.OS_IOS ){
            return 0
        }else {
            return 0
        }
    }

    public static sendFbPurchase (countStr) {   //0是竖屏 1是横屏
        if(cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID){
            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sendFbPurchase","(Ljava/lang/String;)V",countStr)
        }else if ( cc.sys.os == cc.sys.OS_IOS ){
        }else {
        }
    }

    public static copyIntoClip(string : String){
        if(cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID){
            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "copyIntoClip","(Ljava/lang/String;)V",string)
        }else if ( cc.sys.os == cc.sys.OS_IOS ){
            cc.warn("复制内容不支持此平台：",string)
        }else {
            cc.warn("复制内容不支持此平台：",string)
        }
    }
}
